<template>
  <div class="_wz_viewLearningRecords">
    <Card dis-hover :bordered="true" style="margin:10px 0;">
      <p slot="title">学员培训照片</p>
      <div v-if="imgList.length > 0">

        <viewer style="width: 100%;height: 100%;">
          <div class="demo-upload-list" v-for="item in imgList">
            <img :src="apiUrl.imgUrl+item.imgUrl" @error="public.imgDispose" />
          </div>
        </viewer>
        <h6 style="clear: both;"></h6>
      </div>
      <div v-else>暂无学员培训照片信息</div>
    </Card>

    <Card dis-hover :bordered="true" style="margin:10px 0;">
      <p slot="title">学员培训摘要</p>
      <div v-if="digestList.length > 0">
        <Timeline>
          <TimelineItem v-for="item in digestList" :key="item.createTime">
            <p class="content">
              {{item.createTime}} &emsp;
              {{item.summary}}&emsp;
              【{{highlightRowData.materialTrainName}}】
              学习位置:
              <span v-if="!!item.positionDescription">【{{item.positionDescription}}】</span>
              <span v-else>暂无学员培训摘要信息</span></p>
          </TimelineItem>
        </Timeline>
      </div>
      <div v-else>暂无学员培训摘要信息</div>
    </Card>
    <!--图片查看-->
    <Modal title="图片查看" v-model="visible">
      <img :src="imgSrc" v-if="visible" style="width: 100%" @error="public.imgDispose" />
    </Modal>
    <Spin size="large" fix v-if="spinShow"></Spin>

  </div>
</template>
<script>
  export default {
    props: ["highlightRowData"],//接收来自父组件的数据
    data() {
      return {
        spinShow:false,//本页加载
        imgSrc: "",
        visible: false,
        imgList: [],
        digestList: [],
      }
    },
    beforeCreate() {//beforeCreate创建前状态

    },
    created() {//created创建完毕状态

    },
    beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

    },
    mounted() {//mounted 挂载结束状态

      // /trainCourseStudentRecordDetailList
      //
      // /educate/record/plan//trainCourseStudentRecordImgList
      //
      // studentPlanTaskUuid uuid
      let that = this;
      that.spinShow = true;
      //学员照片记录信息
      that.axios.post(that.apiUrl.webApi + "/educate/trainPlan/trainCourseStudentRecordImgList", {studentPlanTaskUuid: that.highlightRowData.uuid}).then(res => {
        if (!!res) {
          that.imgList = res.data.data;
        }
        //学员摘要记录信息
        that.axios.post(that.apiUrl.webApi + "/educate/trainPlan/trainCourseStudentRecordDetailList", {studentPlanTaskUuid: that.highlightRowData.uuid}).then(res => {
          that.spinShow = false;
          if (!!res) {
            that.digestList = res.data.data
          }
        }).catch(err => {
          console.log("失败", err)
        })
      }).catch(err => {
        console.log("失败", err)
      })
    },
    methods: {//执行的方法
//缩略图查看
      handleView(src) {
        this.imgSrc = src;
        this.visible = true;
      },
    },
    watch: {//监听
      highlightRowData(news, old) {
        let that = this;
        that.spinShow = true;
        //学员照片记录信息
        that.axios.post(that.apiUrl.webApi + "/educate/trainPlan/trainCourseStudentRecordImgList", {studentPlanTaskUuid: that.highlightRowData.uuid}).then(res => {
          if (!!res) {
            that.imgList = res.data.data;
          }
          //学员摘要记录信息
          that.axios.post(that.apiUrl.webApi + "/educate/trainPlan/trainCourseStudentRecordDetailList", {studentPlanTaskUuid: that.highlightRowData.uuid}).then(res => {
            that.spinShow = false;
            if (!!res) {
              that.digestList = res.data.data
            }
          }).catch(err => {
            console.log("失败", err)
          })
        }).catch(err => {
          console.log("失败", err)
        })
      },
    },
    beforeUpdate() {//beforeUpdate 更新前状态

    },
    updated() {//updated 更新完成状态

    },
    beforeDestroy() {//beforeDestroy 销毁前状态

    },
    destroyed() {//destroyed 销毁完成状态

    }
  }
</script>
<style lang="less">
  ._wz_viewLearningRecords {
    .demo-upload-list {
      float: left;
      margin: 10px;
      display: block;
      width: 100px;
      height: 132px;
      text-align: center;
      line-height: 60px;
      border: 1px solid transparent;
      border-radius: 4px;
      overflow: hidden;
      background: #fff;
      position: relative;
      box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
      img {
        width: 100%;
        height: 100%;
      }
    }
  }


</style>
